using System;
using System.ServiceProcess;

namespace TripleA.Core.Extensions.WindowsService
{
    /// <summary>
    /// This asserts the windows service is in the expected state (running, stopped etc)
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class WindowsServiceStatusStep<T> : WindowsServiceInstalledStep<T>
    {
        public ServiceControllerStatus Status { get; set; }

        protected override void Inspect(ServiceController serviceController)
        {
            if (serviceController.Status != Status)
                throw new ApplicationException(string.Format("Service '{0}' on '{1}' expected state '{2}', actual state is '{3}'",
                    ServiceName, Machine, Status, serviceController.Status));
        }
    }
}